package com.payment.system.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.payment.common.base.AjaxResult;
import com.payment.common.constant.UserConstants;
import com.payment.common.support.Convert;
import com.payment.common.utils.StringUtils;
import com.payment.system.domain.IndustryMcc;
import com.payment.system.mapper.IndustryMccMapper;
import com.payment.system.service.IIndustryMccService;

/**
 * 行业MCC 服务层实现
 * 
 * @author payment
 * @date 2019-05-09
 */
@Service
public class IndustryMccServiceImpl implements IIndustryMccService 
{
	@Autowired
	private IndustryMccMapper industryMccMapper;

	/**
     * 查询行业MCC信息
     * 
     * @param id 行业MCCID
     * @return 行业MCC信息
     */
    @Override
	public IndustryMcc selectIndustryMccById(String id)
	{
	    return industryMccMapper.selectIndustryMccById(id);
	}
	
	/**
     * 查询行业MCC列表
     * 
     * @param industryMcc 行业MCC信息
     * @return 行业MCC集合
     */
	@Override
	public List<IndustryMcc> selectIndustryMccList(IndustryMcc industryMcc)
	{
	    return industryMccMapper.selectIndustryMccList(industryMcc);
	}
	
    /**
     * 新增行业MCC
     * 
     * @param industryMcc 行业MCC信息
     * @return 结果
     */
	@Override
	public int insertIndustryMcc(IndustryMcc industryMcc)
	{
		industryMcc.setId(StringUtils.randomUUID());
	    return industryMccMapper.insertIndustryMcc(industryMcc);
	}
	
	/**
     * 修改行业MCC
     * 
     * @param industryMcc 行业MCC信息
     * @return 结果
     */
	@Override
	public int updateIndustryMcc(IndustryMcc industryMcc)
	{
	    return industryMccMapper.updateIndustryMcc(industryMcc);
	}

	/**
     * 删除行业MCC对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteIndustryMccByIds(String ids)
	{
		return industryMccMapper.deleteIndustryMccByIds(Convert.toStrArray(ids));
	}

	@Override
	public String checkIndustryMcc(String industryMcc,String id) {
		IndustryMcc mcc = industryMccMapper.selectIndustryMccByMcc(industryMcc);
		if (StringUtils.isNotNull(mcc)&&!mcc.getId().equals(id))
		{
			return UserConstants.USER_EMAIL_NOT_UNIQUE;
		}
		return UserConstants.USER_EMAIL_UNIQUE;
	}

	@Override
	public AjaxResult getMccList() {
		// TODO Auto-generated method stub
		
		return AjaxResult.successAndData("成功", industryMccMapper.selectAllMccList());
	}

}
